package edu.cibertec.actionform;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LoginForm extends ActionForm {
	private String login = null;
	private String password = null;

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public ActionErrors validate(ActionMapping mapping,
			                     HttpServletRequest request) {

		ActionErrors errors = new ActionErrors();

		if (getLogin() == null || getLogin().length() < 1) {
			errors.add("login", new ActionMessage("login.missing"));
		}

		return errors;
	}

	public void reset(ActionMapping mapping, HttpServletRequest request) {
		login = null;
		password = null;
		
	}

}
